package com.xyh.seckill.config;

import com.xyh.seckill.service.SecKillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * 秒杀任务定时上架，上架最近三天需要秒杀的商品
 *      每天晚上3点，商家最近三天需要秒杀的商品
 *      当天 00:00:00-23:59:59
 *      明天 00:00:00-23:59:59
 *      后天 00:00:00-23:59:59
 */
@Slf4j
@Service
public class ScheduledConfig {

    @Autowired
    SecKillService secKillService;

    @Scheduled(cron = "0 0 3 * * ?")
    public void uploadSecKillSkuLatest3ays(){
        //1.重复商品无需上架
        secKillService.uploadSecKillSkuLatest3ays();
    }
}
